package com.lyEducation.controllers.dto.system;

import com.lyEducation.entities.system.SysUserEntity;
import lombok.Getter;

import java.util.Date;
import java.util.Objects;
import java.util.TreeSet;
@Getter
public class SysUserDto {
  private String nickName;
  private String identityCard;
  private boolean sex;
  private Date birthTime;
  private Integer age;
  private String birthday;
  private String email;
  private String phone;
  private String mobile;
  private String photoPath;
  private TreeSet<SysMenuDto> menuSet;

  public SysUserDto(
          SysUserEntity sysUserEntity) {
    this.nickName = sysUserEntity.getName();
    this.identityCard = sysUserEntity.getIdentityCard();
    this.sex = sysUserEntity.getSex();
    this.birthTime = sysUserEntity.getBirthTime();
    this.age = sysUserEntity.getAge();
    this.birthday = sysUserEntity.getBirthday();
    this.email = sysUserEntity.getEmail();
    this.phone = sysUserEntity.getPhone();
    this.mobile = sysUserEntity.getMobile();
    this.photoPath = sysUserEntity.getPhoto();
    this.menuSet = SysMenuDto.createSysMenuDtoSet(sysUserEntity.getMenus());
  }

  public TreeSet<SysMenuDto> getMenuSet() {
    return menuSet;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof SysUserDto)) return false;
    SysUserDto that = (SysUserDto) o;
    return sex == that.sex &&
            Objects.equals(nickName, that.nickName) &&
            Objects.equals(identityCard, that.identityCard) &&
            Objects.equals(birthTime, that.birthTime) &&
            Objects.equals(age, that.age) &&
            Objects.equals(birthday, that.birthday) &&
            Objects.equals(email, that.email) &&
            Objects.equals(phone, that.phone) &&
            Objects.equals(mobile, that.mobile) &&
            Objects.equals(photoPath, that.photoPath) &&
            Objects.equals(menuSet, that.menuSet);
  }

  @Override
  public int hashCode() {

    return Objects.hash(nickName, identityCard, sex, birthTime, age, birthday, email, phone, mobile, photoPath, menuSet);
  }
}
